home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Constructors for objects that can be FALSE
- Date: Thu, 15 Feb 1996 14:16:57 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <31233249.2781E494@intellektik.informatik.th-darmstadt.de>
- References: <4fusaq$g1e@due.unit.no>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3 sun4m)
-
- Rolf Rustad wrote:
- >
- > Hi
- > I'm writting control software for instrumentation applications, using BC++.
- > I'm creating classes, like Camera and Syntesizer etc.
- > What I would like is to make objects of these classes evaluate to FALSE
- > if the physical device is not present or available, as do for instanse
- > ifpstream:
- >
- > ifpstream is(filename);
- > if(!is){
- > .
- > .
- > }
- >
- > How do I write the constructor??
- >
-
- That effect is usually achieved by providing an appropriate
- conversion operator. For instance, you may add sth. like
-
- operator bool () const { return phys_dev_avail; }
-
- to your class.
-
- Enno
-